#include <cstdio>
#include <algorithm>
using namespace std;
int main(void){
    int t;
    scanf("%d",&t);
    long long n;
    while(t--){
        scanf("%lld",&n);
        if(n%3==0){
            printf("%lld\n",(n/3)*(n/3)*(n/3));
        }
        else if(n%4==0){
            printf("%lld\n",(n/4)*(n/4)*(n/2));
        }
        else{
            printf("-1\n");
        }
    }
    return 0;
}
